#include <chrono>
#include <iostream>
#include "Logger.hpp"
#include "TimerQueue.hpp"

void test()
{

  LOG_DEBUG << "[test] : test timerQue happended ";

  std::cout << "[test] : test timerQue happended at " << std::chrono::system_clock::now().time_since_epoch() / std::chrono::microseconds(1) << std::endl;

}


int main()
{

  //Logger::setLogLevel(Logger::TRACE);

  TimerQueue* timer_queue = TimerQueue::GetInstance();
  timer_queue->Start();
  timer_queue->runAfter(1.0, test);
  timer_queue->runAfter(1.0, test);
  timer_queue->runAfter(3.0, test);

  //auto tid = timer_queue->runEvery(5.0, test);

  auto tid = timer_queue->runEvery(5.0, [] {   
    std::cout << "[test] : test timerQue happended lambda" << std::endl;
    test();
  });

  getchar();
  
  timer_queue->cancel(tid);

  getchar();
  return 0;
}

